package com.example.demo.web;

import com.example.demo.dao.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController2 {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/getAllusers", method = RequestMethod.GET)
    public Integer getAllUsers(){
        return userService.getAllUsers();
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public void add(@ModelAttribute String name, @ModelAttribute Integer age){
        userService.create(name,age);
    }
}
